<template>
  <d2-container>
    <div class="d2-breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>系统管理</el-breadcrumb-item>
        <el-breadcrumb-item>角色管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-form :inline="true" class="SearchForm">
      <el-form-item>
        <router-link to="roles/add">
          <el-button type="success">新增角色</el-button>
        </router-link>
      </el-form-item>
      <el-form-item label="活动区域">
    <el-select v-model="form.region" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
      <el-form-item>
        <el-input placeholder="角色名称" type="text" v-model.trim="searchForm.Name" ></el-input>
      </el-form-item>
      <el-button type="primary" @click="search()" icon="el-icon-search">查询</el-button>
      <el-button type="danger" icon="el-icon-refresh" @click="reset">重置</el-button>
    </el-form>
    <el-table border :data="tableData.account">
      <el-table-column label="角色名称"  align="center" prop="MtuUname"></el-table-column>
      <el-table-column label="状态"  align="center" prop="MtuStatus">
        <template slot-scope="scope">{{scope.row.MtuStatus == 1 ? '启用' : '禁用'}}</template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <router-link :to="`/system/edit_account/${scope.row.id}`">
            <el-button type="text">详情/编辑</el-button>
          </router-link>
          <el-button type="text" class="margin-left" @click="deleteInfo(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="search"
      @current-change="search"
      :current-page.sync="page"
      :page-sizes="[10, 25, 50, 100]"
      :page-size.sync="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.Count"
    ></el-pagination>
  </d2-container>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      searchForm: {
        Name: ""
      },
      searchSelect: {
        type: []
      },
      tableData: {
        account: [
          {
            Id: "001",
            MtuUname: "开发",
            MtuStatus: 1
          }
        ],
        Count: 0
      },
      page: 1,
      pageSize: 10
    };
  },
  methods: {
    search() {
      let params = {
        page: this.page,
        page_size: this.pageSize
      };
      if (this.searchForm.Name != "") {
        params.Name = this.searchForm.Name;
      }
      this.$axios.post("/admin/system/selacc", params).then(result => {
        if (result.code == 200) {
          this.tableData = result.data.data;
        } else {
          this.$message.error(result.data.msg);
        }
      });
    },
    reset() {
      this.searchForm = {
      };
      this.search();
    },
    deleteInfo(id) {
      const _this = this;
      this.$confirm("确定删除该角色信息？", "确认删除", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        closeOnPressEscape: false,
        closeOnClickModal: false
      })
        .then(() => {
          let params = {
            PsId,
            id
          };
          _this.$axios
            .post("/product/delseries", params)
            .then(res => {
              if (res.data.Code == -1) {
                _this.$message({
                  message: res.data.Msg,
                  type: "error"
                });
              } else {
                _this.$message({
                  message: "删除成功",
                  type: "success"
                });
                _this.search();
              }
            })
            .catch(err => {
              this.$message({
                message: err,
                type: "error"
              });
            });
        })
        .catch(() => {});
    }
  },
  created() {
    this.search();
  }
};
</script>

<style scoped lang="scss">
</style>
